//app.js
App({
  onLaunch: function () {
    var that=this;
    console.log('onLaunch')
    wx.cloud.init({});//初始化云开发
    const db = wx.cloud.database({});
    var i=1;
    for(;i<=3;i++)
    {
      
      db.collection("cafeteria" + i).doc("person_num"+i).get({
        //如果查询成功的话    
      }).then(res=>{
        console.log(res.data)
        //因为从数据库请求数据有延迟，所以到这里时i已经变成4了，不能用i来判断数据
        if (res.data._id[10] == '1') that.globalData.cafeteria1_num = res.data.person_num;
        else if (res.data._id[10] == '2') that.globalData.cafeteria2_num = res.data.person_num;
        else if (res.data._id[10] == '3')that.globalData.cafeteria3_num = res.data.person_num;
      })
    }
  },
  globalData: {
    this_detect:1,
    cafeteria1_num:0,
    cafeteria2_num: 0,
    cafeteria3_num: 0,
  }
})